<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
      
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paraCode" label="参数code">
          <a-input placeholder="请输入参数code" v-model="model.paraCode" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmlId" label="来源XML的ID">
          <a-input placeholder="请输入来源XML的ID" v-model="model.xmlId" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paraName" label="参数名字">
          <a-input placeholder="请输入参数名字" v-model="model.paraName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paraType" label="参数类型">
          <a-input placeholder="请输入参数类型" v-model="model.paraType" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bit" label="比特位">
          <a-input placeholder="请输入比特位" v-model="model.bit" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unit" label="单位">
          <a-input placeholder="请输入单位" v-model="model.unit" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sort" label="排序">
          <a-input placeholder="请输入排序" v-model="model.sort" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paraRange" label="范围">
          <a-input placeholder="请输入范围" v-model="model.paraRange" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag" label="删除标记 0否 1是">
          <a-input placeholder="请输入删除标记 0否 1是" v-model="model.delFlag" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paraFlag" label="参数标记 (sys)系统参数 (user)自定义参数">
          <a-input placeholder="请输入参数标记 (sys)系统参数 (user)自定义参数" v-model="model.paraFlag" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="func" label="自定义参数公式">
          <a-input placeholder="请输入自定义参数公式" v-model="model.func" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idFunc" label="系统id 逗号分隔">
          <a-input placeholder="请输入系统id 逗号分隔" v-model="model.idFunc" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="binaryCode" label="进制，1:浮点数2:16进制 3:时间码4:10进制 5:2进制 6:其他">
          <a-input placeholder="请输入进制，1:浮点数2:16进制 3:时间码4:10进制 5:2进制 6:其他" v-model="model.binaryCode" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="frequency" label="频率">
          <a-input placeholder="请输入频率" v-model="model.frequency" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="meaning" label="图像参数的意义">
          <a-input placeholder="请输入图像参数的意义" v-model="model.meaning" />
        </a-form-model-item>
		
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import moment from "moment"

  export default {
    name: "GdqvParaModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        delFlag:[{ required: true, message: '请输入删除标记 0否 1是!' }],
        },
        url: {
          add: "/test/gdqvPara/add",
          edit: "/test/gdqvPara/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        //初始化默认值
        this.edit({});
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // 触发表单验证
         this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false;
          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>